<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>升级</title>
	<link rel="stylesheet" href="/index/css/common.css?v=2">
	<link rel="stylesheet" href="/index/css/level.css">
	<style>
		.active{
			border:1px solid red;
		}
	</style>
</head>

<body>
	<div class="tabsBox">
		<div class="topTab">
			<div class="tabLeft">
				<img src="/index/assets/left_J.png" >
			</div>
			<div class="tabCenter">开通会员</div>
			<div class="tabRight">特权说明</div>
		</div>
	</div>
	<div class="upgrade">
		<div class="couponList">
			{foreach $levels as $k=> $v}
			<div class="couponImg {if $k==0} active {/if}" level_id="{$v.id}" price="{$v.price}" >
				<!--<img src="/index/assets/coupon.jpg" class="couponBac" >-->
				<img src="{:config('api.oss_img_path')}{$v.image}" class="couponBac" >
				<div class="upgradeBox cleardrift">
					<!--<div class="u_left">-->
						<!--<img src="/index/assets/upgrade.png" >-->
						<!--<div class="u_grade">-->
							<!--<div class="userGrade">{$v.level_name}</div>-->
							<!--<div class="userState">{if $v.id==$user_level}已开通{else/}未开通{/if}</div>-->
						<!--</div>-->
					<!--</div>-->
					<!--<div class="u_right">￥{$v.price} 元</div>-->
				</div>
				<div class="styleBox cleardrift">
					<div class="styleList cleardrift">
						<!--<div class="yuan"></div>-->
						<div class="styleCon">{$v.intro}</div>
					</div>

					<div class="styleList cleardrift" style="float: right">

						<div class="styleCon">
							<div class="yuan"></div>
							直接邀请奖励:
							<span>{$v.commission1}%</span>
						</div>
						{if $v.commission2>0}
						<div class="styleCon">
							<div class="yuan"></div>
							间接邀请奖励:
							<span>{$v.commission2}%</span>
						</div>
						{/if}

					</div>

				</div>
			</div>
			{/foreach}
			
			
		</div>
	</div>
	<!-- 弹窗 -->
	<div class="shuoming">
		<div class="cleardrift">
			<img src="/index/assets/close.png" class="close cleardrift" >
		</div>
		<div style="width:100%;">{$help.content|raw}</div>
	</div>

	<div style="height:50px;"></div>
	<!-- 立即购买 -->
	<div class="classBtm cleardrift">
		<div class="classMoney">￥<span >{$levels[0]['price']}</span></div>
		<div class="classBtn">立即购买</div>
	</div>
</body>
{include file='common/toast'}
<script type="text/javascript" src="/index/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/index/js/clipboard.min.js"></script>
<script src="/index/js/common.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<script>

	// var url = document.URL   //获取当前页面的网址信息
	// var num = url.indexOf('#');  //获取＃在的位置信息
	// console.log(num);
	// if (num){
		// URL = url.substring(0,num);  //截取网址信息
		// history.pushState(null,null,url+'?code=3');  //将网址设置
	// }

	$('.tabRight').click(function(){
		$('.shuoming').fadeIn(500)
        $.get('{:url("explain/helpHits",["id"=>$help.id])}','',function(){})

    })
	$('.close').click(function(){
		$('.shuoming').fadeOut(500)
	})

	var level_id = 0;
	$(".couponImg").click(function(){
		level_id = $(this).attr('level_id');
	    var price = $(this).attr('price');

	    $('.classMoney span').text(price);

	    $(this).addClass('active').siblings().removeClass('active')
	})

	var flag = true;
	$('.classBtn').click(function(){

	    if(flag==false){
	        return;
		}

		flag = false;
	    var level =  $('.active').attr('level_id');

	    if(level>0){
            toast.loading({
                title:"支付中",
//                duration:2000
            })
			$.post('{:url("pay/payLevel")}',{level:level},function(res){

                flag = true;
			    toast.hide();
			    if(res.code==1){

			        console.log(res.data);
                    WeixinJSBridge.invoke(
                        'getBrandWCPayRequest',
//						{
//                            "appId":res.data.appid, //公众号名称，由商户传入
//                            "timeStamp":''+res.data.time, //时间戳，自1970年以来的秒数
//                            "nonceStr":res.data.nonce_str, //随机串
//                            "package":"prepay_id="+res.data.prepay_id,   //订单详情扩展字符串
//                            "signType":"MD5", //微信签名方式：
//                            "paySign":res.data.sign //微信签名
//                        },
                         res.data,

                        function(msg) {
                            if (msg.err_msg == "get_brand_wcpay_request:ok") {
                                // 表示已经支付,res.err_msg将在用户支付成功后返回 ok。

                                if(res.phone==''){

                                    toastSuccess('支付成功', '{:url("mine/bindPhone")}?reg=2');

                                }else{
                                    toastSuccess('支付成功','{:url("mine/index")}');
                                }
//                                window.location.href = ;
                            } else {
                                console.log(msg)
                                toastFail('支付失败');
                            }
                        })
				}else{
			        toastFail(res.msg);
				}
			},'json')
		}else{
	        toastFail('请选择等级');
		}
	})

</script>
</html>